package com.oneday.nuo.base.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.oneday.nuo.base.dto.NuoDictDTO;
import com.oneday.nuo.base.response.NuoResult;
import com.oneday.nuo.base.service.NuoDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * (NuoDict)表控制层
 *
 * @author liushuai
 * @since 2021-03-13 23:37:13
 */
@RestController
@RequestMapping("api/dict")
@Api(tags="NuoDictController")
@ApiModel(value = "",description = "字典表")
public class NuoDictController {
    @Autowired
    private NuoDictService nuoDictService;

    @PostMapping("saveDict")
    @ApiOperation(value = "保存字典类型" ,  notes="保存字典类型")
    public NuoResult saveDict(@RequestBody NuoDictDTO nuoDictDTO){
        nuoDictService.saveDict(nuoDictDTO);
        return  NuoResult.buildResponseSave();
    }
    @GetMapping("queryDictPageByParam")
    @ApiOperation(value = "根据参数分页查询字典类型" ,  notes="根据参数分页查询字典类型")
    public NuoResult queryDictPageByParam(Page page, NuoDictDTO queryDTO) {
        IPage<NuoDictDTO> dtos = nuoDictService.queryDictPageByParam(page,queryDTO);
        return NuoResult.buildResponseQuery(dtos);
    }
    @GetMapping("queryDictById")
    @ApiOperation(value = "根据id查询字典" ,  notes="根据id查询字典")
    public NuoResult queryDictById(@RequestParam("id") String id){
        NuoDictDTO dto = nuoDictService.queryDictById(id);
        return NuoResult.buildResponseQuery(dto);

    }
    @GetMapping("deleteDictById")
    @ApiOperation(value = "根据id删除字典" ,  notes="根据id删除字典")
    public NuoResult deleteDictById(@RequestParam("id") String id){
        nuoDictService.deleteDictById(id);
        return  NuoResult.buildResponseDelete();
    }


}
